package com.xue.mybatis.controller;

import com.xue.mybatis.entity.DataSourceInfo;
import com.xue.mybatis.entity.User;
import com.xue.mybatis.mapper.UserMapper;
import com.xue.mybatis.service.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RestController
@RequestMapping("user")
public class UserController {

    @Autowired
    private UserMapper userMapper;
    @Autowired
    private UserService userService;
    @Autowired
    private DataSourceInfo info;

    @GetMapping("getList")
    public User getList(){
        System.out.println("数据库连接url>>>>>"+info.getUrl());
        System.out.println("数据库连接账号>>>>>"+info.getUsername());
        System.out.println("数据库连接密码>>>>>"+info.getPassword());
        System.out.println("数据库连接驱动>>>>>"+info.getDriverName());
        return userMapper.selectById(2);

    }

    @GetMapping("findList")
    public List<User> findList(){
        return userService.findList();
    }
}
